/*
 * @lc app=leetcode.cn id=2028 lang=cpp
 *
 * [2028] 找出缺失的观测数据
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <stdlib>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>

using namespace std;
// @lc code=start
class Solution {
public:
    vector<int> missingRolls(vector<int>& rolls, int mean, int n) {
        vector<int> ret;
        int m = rolls.size();
        int sum = 0;
        for(int x : rolls) {
            sum += x;
        }
        int diff = mean *(m + n) - sum;
        int i = 6;
        if(diff > n*i || mean <= sum/(m+n)) {
            return ret;
        }
        while(diff && i) {
            if((diff - i) >= n - 1) {
                diff -= i;
                n--;
                ret.push_back(i);
            }else {
                i--;
            }
        }
        return ret;
    }
};
// @lc code=end

